
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Flink中Keyby和线程数的疑问 · 继松的书</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="jisong">
        
        
    
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-prism/prism-base16-ateliersulphurpool.light.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-ace/ace.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="or03-Flink-Spark-Storm的区别.html" />
    
    
    <link rel="prev" href="or01-初学 Flink.html" />
    

    
    <link rel="stylesheet" href="../../gitbook/gitbook-plugin-chart/c3/c3.min.css">
    <script src="../../gitbook/gitbook-plugin-chart/c3/d3.min.js"></script>
    <script src="../../gitbook/gitbook-plugin-chart/c3/c3.min.js"></script>
    

    <script src="../../gitbook/gitbook-plugin-graph/d3.min.js"></script>
    <script src="../../gitbook/gitbook-plugin-graph/function-plot.js"></script>    

    
        <link rel="shortcut icon" href='../../favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://ji-song.gitee.io/cc" target="_blank" class="custom-link">Home</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                        <b>1.1.</b>
                    
                    继松的笔记
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Developer</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="0-README.html">
            
                <a href="0-README.html">
            
                    
                        <b>2.1.</b>
                    
                    Flink
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="or01-初学 Flink.html">
            
                <a href="or01-初学 Flink.html">
            
                    
                        <b>2.1.1.</b>
                    
                    初学 Flink
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.1.2" data-path="or02-Flink中Keyby和线程数的疑问.html">
            
                <a href="or02-Flink中Keyby和线程数的疑问.html">
            
                    
                        <b>2.1.2.</b>
                    
                    Flink中Keyby和线程数的疑问
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="or03-Flink-Spark-Storm的区别.html">
            
                <a href="or03-Flink-Spark-Storm的区别.html">
            
                    
                        <b>2.1.3.</b>
                    
                    Flink-Spark-Storm的区别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="or04-Flink 异常笔记.html">
            
                <a href="or04-Flink 异常笔记.html">
            
                    
                        <b>2.1.4.</b>
                    
                    Flink 异常笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../JDK/0-README.html">
            
                <a href="../JDK/0-README.html">
            
                    
                        <b>2.2.</b>
                    
                    JDK
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="../JDK/Lock/0-README.html">
            
                <a href="../JDK/Lock/0-README.html">
            
                    
                        <b>2.2.1.</b>
                    
                    Lock
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1.1" data-path="../JDK/Lock/AQS.html">
            
                <a href="../JDK/Lock/AQS.html">
            
                    
                        <b>2.2.1.1.</b>
                    
                    AQS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.2" data-path="../JDK/Lock/LinkedBlockingQueue.html">
            
                <a href="../JDK/Lock/LinkedBlockingQueue.html">
            
                    
                        <b>2.2.1.2.</b>
                    
                    LinkedBlockingQueue
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.3" data-path="../JDK/Lock/ReadWriteLock.html">
            
                <a href="../JDK/Lock/ReadWriteLock.html">
            
                    
                        <b>2.2.1.3.</b>
                    
                    ReadWriteLock
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.4" data-path="../JDK/Lock/[12090055]ReentrantLock.html">
            
                <a href="../JDK/Lock/[12090055]ReentrantLock.html">
            
                    
                        <b>2.2.1.4.</b>
                    
                    ReentrantLock
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.2" data-path="../JDK/Period 时间坑.html">
            
                <a href="../JDK/Period 时间坑.html">
            
                    
                        <b>2.2.2.</b>
                    
                    Period 时间坑
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3" data-path="../JDK/Pool/0-README.html">
            
                <a href="../JDK/Pool/0-README.html">
            
                    
                        <b>2.2.3.</b>
                    
                    Pool
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.3.1" data-path="../JDK/Pool/ThreadPoolExecutor.html">
            
                <a href="../JDK/Pool/ThreadPoolExecutor.html">
            
                    
                        <b>2.2.3.1.</b>
                    
                    ThreadPoolExecutor
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.2" data-path="../JDK/Pool/多线程并发导致CPU100%的一种原因和解决方式.html">
            
                <a href="../JDK/Pool/多线程并发导致CPU100%的一种原因和解决方式.html">
            
                    
                        <b>2.2.3.2.</b>
                    
                    多线程并发导致CPU100%的一种原因和解决方式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.4" data-path="../JDK/Proxy的工作原理[0%].html">
            
                <a href="../JDK/Proxy的工作原理[0%].html">
            
                    
                        <b>2.2.4.</b>
                    
                    Proxy的工作原理[0%]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.5" data-path="../JDK/Util/0-README.html">
            
                <a href="../JDK/Util/0-README.html">
            
                    
                        <b>2.2.5.</b>
                    
                    Util
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.5.1" data-path="../JDK/Util/HashMap.html">
            
                <a href="../JDK/Util/HashMap.html">
            
                    
                        <b>2.2.5.1.</b>
                    
                    HashMap
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../JVM/0-README.html">
            
                <a href="../JVM/0-README.html">
            
                    
                        <b>2.3.</b>
                    
                    JVM
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="../JVM/or01-内存区域.html">
            
                <a href="../JVM/or01-内存区域.html">
            
                    
                        <b>2.3.1.</b>
                    
                    内存区域
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.2" data-path="../JVM/or02-内存模型.html">
            
                <a href="../JVM/or02-内存模型.html">
            
                    
                        <b>2.3.2.</b>
                    
                    内存模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.3" data-path="../JVM/or03-内存优化.html">
            
                <a href="../JVM/or03-内存优化.html">
            
                    
                        <b>2.3.3.</b>
                    
                    内存优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.4" data-path="../JVM/or04-JVM参数集.html">
            
                <a href="../JVM/or04-JVM参数集.html">
            
                    
                        <b>2.3.4.</b>
                    
                    JVM参数集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.5" data-path="../JVM/or05-JVM指令集.html">
            
                <a href="../JVM/or05-JVM指令集.html">
            
                    
                        <b>2.3.5.</b>
                    
                    JVM指令集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.6" data-path="../JVM/or06-垃圾收集器.html">
            
                <a href="../JVM/or06-垃圾收集器.html">
            
                    
                        <b>2.3.6.</b>
                    
                    垃圾收集器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.7" data-path="../JVM/or07-垃圾收集器优化.html">
            
                <a href="../JVM/or07-垃圾收集器优化.html">
            
                    
                        <b>2.3.7.</b>
                    
                    垃圾收集器优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.8" data-path="../JVM/or08-Arthus.html">
            
                <a href="../JVM/or08-Arthus.html">
            
                    
                        <b>2.3.8.</b>
                    
                    Arthus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.9" data-path="../JVM/or09-Sychronized.html">
            
                <a href="../JVM/or09-Sychronized.html">
            
                    
                        <b>2.3.9.</b>
                    
                    Sychronized
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../Kafka/0-README.html">
            
                <a href="../Kafka/0-README.html">
            
                    
                        <b>2.4.</b>
                    
                    Kafka
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="../Kafka/Kafka高吞吐量的原理[0%].html">
            
                <a href="../Kafka/Kafka高吞吐量的原理[0%].html">
            
                    
                        <b>2.4.1.</b>
                    
                    Kafka高吞吐量的原理[0%]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.2" data-path="../Kafka/kafka的消费时机.html">
            
                <a href="../Kafka/kafka的消费时机.html">
            
                    
                        <b>2.4.2.</b>
                    
                    kafka的消费时机
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.3" data-path="../Kafka/参数详解[1%].html">
            
                <a href="../Kafka/参数详解[1%].html">
            
                    
                        <b>2.4.3.</b>
                    
                    参数详解[1%]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.4" data-path="../Kafka/问题点[1%].html">
            
                <a href="../Kafka/问题点[1%].html">
            
                    
                        <b>2.4.4.</b>
                    
                    问题点[1%]
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../MySQL/0-README.html">
            
                <a href="../MySQL/0-README.html">
            
                    
                        <b>2.5.</b>
                    
                    MySQL
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.5.1" data-path="../MySQL/B树.html">
            
                <a href="../MySQL/B树.html">
            
                    
                        <b>2.5.1.</b>
                    
                    B树
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.2" data-path="../MySQL/MySQL 处理重复数据.html">
            
                <a href="../MySQL/MySQL 处理重复数据.html">
            
                    
                        <b>2.5.2.</b>
                    
                    MySQL 处理重复数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.3" data-path="../MySQL/MySQL常用命令.html">
            
                <a href="../MySQL/MySQL常用命令.html">
            
                    
                        <b>2.5.3.</b>
                    
                    MySQL常用命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.4" data-path="../MySQL/MySQL数据类型.html">
            
                <a href="../MySQL/MySQL数据类型.html">
            
                    
                        <b>2.5.4.</b>
                    
                    MySQL数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.5" data-path="../MySQL/explain.html">
            
                <a href="../MySQL/explain.html">
            
                    
                        <b>2.5.5.</b>
                    
                    explain
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.6" data-path="../MySQL/写SQL的注意点.html">
            
                <a href="../MySQL/写SQL的注意点.html">
            
                    
                        <b>2.5.6.</b>
                    
                    写SQL的注意点
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="../Python/0-README.html">
            
                <a href="../Python/0-README.html">
            
                    
                        <b>2.6.</b>
                    
                    Python
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="../Redis/0-README.html">
            
                <a href="../Redis/0-README.html">
            
                    
                        <b>2.7.</b>
                    
                    Redis
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.7.1" data-path="../Redis/Jedis常见问题汇总.html">
            
                <a href="../Redis/Jedis常见问题汇总.html">
            
                    
                        <b>2.7.1.</b>
                    
                    Jedis常见问题汇总
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.2" data-path="../Redis/Redis info详解.html">
            
                <a href="../Redis/Redis info详解.html">
            
                    
                        <b>2.7.2.</b>
                    
                    Redis info详解
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="../Spring/0-README.html">
            
                <a href="../Spring/0-README.html">
            
                    
                        <b>2.8.</b>
                    
                    Spring
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.8.1" data-path="../Spring/Spring AOP详解[0%].html">
            
                <a href="../Spring/Spring AOP详解[0%].html">
            
                    
                        <b>2.8.1.</b>
                    
                    Spring AOP详解[0%]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8.2" data-path="../Spring/Spring 容器里都装了哪些bean.html">
            
                <a href="../Spring/Spring 容器里都装了哪些bean.html">
            
                    
                        <b>2.8.2.</b>
                    
                    Spring 容器里都装了哪些bean
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8.3" data-path="../Spring/[11770408]Spring-Cache手动清缓存.html">
            
                <a href="../Spring/[11770408]Spring-Cache手动清缓存.html">
            
                    
                        <b>2.8.3.</b>
                    
                    Spring-Cache手动清缓存
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="../kotlin/0-README.html">
            
                <a href="../kotlin/0-README.html">
            
                    
                        <b>2.9.</b>
                    
                    kotlin
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="../工作心得/0-README.html">
            
                <a href="../工作心得/0-README.html">
            
                    
                        <b>2.10.</b>
                    
                    工作心得
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.10.1" data-path="../工作心得/HttpClient高并发下性能优化-http连接池.html">
            
                <a href="../工作心得/HttpClient高并发下性能优化-http连接池.html">
            
                    
                        <b>2.10.1.</b>
                    
                    HttpClient高并发下性能优化-http连接池
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.2" data-path="../工作心得/List 快速去重.html">
            
                <a href="../工作心得/List 快速去重.html">
            
                    
                        <b>2.10.2.</b>
                    
                    List 快速去重
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.3" data-path="../工作心得/MAVEN依赖问题.html">
            
                <a href="../工作心得/MAVEN依赖问题.html">
            
                    
                        <b>2.10.3.</b>
                    
                    MAVEN依赖问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.4" data-path="../工作心得/MyBatis使用JDK8的日期类Handler.html">
            
                <a href="../工作心得/MyBatis使用JDK8的日期类Handler.html">
            
                    
                        <b>2.10.4.</b>
                    
                    MyBatis使用JDK8的日期类Handler
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.5" data-path="../工作心得/Mybatis缓存笔记.html">
            
                <a href="../工作心得/Mybatis缓存笔记.html">
            
                    
                        <b>2.10.5.</b>
                    
                    Mybatis缓存笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.6" data-path="../工作心得/Mybatis配置详解.html">
            
                <a href="../工作心得/Mybatis配置详解.html">
            
                    
                        <b>2.10.6.</b>
                    
                    Mybatis配置详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.7" data-path="../工作心得/log4j动态修改日志级别.html">
            
                <a href="../工作心得/log4j动态修改日志级别.html">
            
                    
                        <b>2.10.7.</b>
                    
                    log4j动态修改日志级别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.8" data-path="../工作心得/收藏的文章.html">
            
                <a href="../工作心得/收藏的文章.html">
            
                    
                        <b>2.10.8.</b>
                    
                    收藏的文章
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.9" data-path="../工作心得/数据不一致问题.html">
            
                <a href="../工作心得/数据不一致问题.html">
            
                    
                        <b>2.10.9.</b>
                    
                    数据不一致问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.10" data-path="../工作心得/站会制度.html">
            
                <a href="../工作心得/站会制度.html">
            
                    
                        <b>2.10.10.</b>
                    
                    站会制度
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.11" data-path="../微服务/0-README.html">
            
                <a href="../微服务/0-README.html">
            
                    
                        <b>2.11.</b>
                    
                    微服务
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.11.1" data-path="../微服务/dubbo-注入spring为空.html">
            
                <a href="../微服务/dubbo-注入spring为空.html">
            
                    
                        <b>2.11.1.</b>
                    
                    dubbo-注入spring为空
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.11.2" data-path="../微服务/dubbo在zk中都存了哪些东西[10%].html">
            
                <a href="../微服务/dubbo在zk中都存了哪些东西[10%].html">
            
                    
                        <b>2.11.2.</b>
                    
                    dubbo在zk中都存了哪些东西[10%]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.11.3" data-path="../微服务/zookeeper命令[1%].html">
            
                <a href="../微服务/zookeeper命令[1%].html">
            
                    
                        <b>2.11.3.</b>
                    
                    zookeeper命令[1%]
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">OS</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../../OS/Linux/0-README.html">
            
                <a href="../../OS/Linux/0-README.html">
            
                    
                        <b>3.1.</b>
                    
                    Linux
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1.1" data-path="../../OS/Linux/Deepin Linux安装wine5.0.html">
            
                <a href="../../OS/Linux/Deepin Linux安装wine5.0.html">
            
                    
                        <b>3.1.1.</b>
                    
                    Deepin Linux安装wine5.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.2" data-path="../../OS/Linux/Deepin修改使用aliyun的软件源.html">
            
                <a href="../../OS/Linux/Deepin修改使用aliyun的软件源.html">
            
                    
                        <b>3.1.2.</b>
                    
                    Deepin修改使用aliyun的软件源
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.3" data-path="../../OS/Linux/Linux最常用命令.html">
            
                <a href="../../OS/Linux/Linux最常用命令.html">
            
                    
                        <b>3.1.3.</b>
                    
                    Linux最常用命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.4" data-path="../../OS/Linux/TOP命令.html">
            
                <a href="../../OS/Linux/TOP命令.html">
            
                    
                        <b>3.1.4.</b>
                    
                    TOP命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.5" data-path="../../OS/Linux/bash_alias.html">
            
                <a href="../../OS/Linux/bash_alias.html">
            
                    
                        <b>3.1.5.</b>
                    
                    bash_alias
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.6" data-path="../../OS/Linux/dpkg.html">
            
                <a href="../../OS/Linux/dpkg.html">
            
                    
                        <b>3.1.6.</b>
                    
                    dpkg
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.7" data-path="../../OS/Linux/find.html">
            
                <a href="../../OS/Linux/find.html">
            
                    
                        <b>3.1.7.</b>
                    
                    find
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.8" data-path="../../OS/Linux/oh-my-zsh.html">
            
                <a href="../../OS/Linux/oh-my-zsh.html">
            
                    
                        <b>3.1.8.</b>
                    
                    oh-my-zsh
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../../OS/Mac/0-README.html">
            
                <a href="../../OS/Mac/0-README.html">
            
                    
                        <b>3.2.</b>
                    
                    Mac
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.2.1" data-path="../../OS/Mac/MacBook安装brew.html">
            
                <a href="../../OS/Mac/MacBook安装brew.html">
            
                    
                        <b>3.2.1.</b>
                    
                    MacBook安装brew
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../../OS/Windows/0-README.html">
            
                <a href="../../OS/Windows/0-README.html">
            
                    
                        <b>3.3.</b>
                    
                    Windows
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1" data-path="../../OS/Windows/WSL的ssh-agent问题.html">
            
                <a href="../../OS/Windows/WSL的ssh-agent问题.html">
            
                    
                        <b>3.3.1.</b>
                    
                    WSL的ssh-agent问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.2" data-path="../../OS/Windows/windows10使用任务计划提醒自己.html">
            
                <a href="../../OS/Windows/windows10使用任务计划提醒自己.html">
            
                    
                        <b>3.3.2.</b>
                    
                    windows10使用任务计划提醒自己
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.3" data-path="../../OS/Windows/win下的终端使用指南.html">
            
                <a href="../../OS/Windows/win下的终端使用指南.html">
            
                    
                        <b>3.3.3.</b>
                    
                    win下的终端使用指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">TOOLS</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../../TOOLS/IDEA/0-README.html">
            
                <a href="../../TOOLS/IDEA/0-README.html">
            
                    
                        <b>4.1.</b>
                    
                    IDEA
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../../TOOLS/IDEA/IDEA配置终端.html">
            
                <a href="../../TOOLS/IDEA/IDEA配置终端.html">
            
                    
                        <b>4.1.1.</b>
                    
                    IDEA配置终端
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../../TOOLS/IDEA/去掉重复代码的提醒.html">
            
                <a href="../../TOOLS/IDEA/去掉重复代码的提醒.html">
            
                    
                        <b>4.1.2.</b>
                    
                    去掉重复代码的提醒
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" data-path="../../TOOLS/IDEA/字体JetBrain mono.html">
            
                <a href="../../TOOLS/IDEA/字体JetBrain mono.html">
            
                    
                        <b>4.1.3.</b>
                    
                    字体JetBrain mono
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" data-path="../../TOOLS/IDEA/常用插件.html">
            
                <a href="../../TOOLS/IDEA/常用插件.html">
            
                    
                        <b>4.1.4.</b>
                    
                    常用插件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" data-path="../../TOOLS/IDEA/自定义TODO.html">
            
                <a href="../../TOOLS/IDEA/自定义TODO.html">
            
                    
                        <b>4.1.5.</b>
                    
                    自定义TODO
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../../TOOLS/checkstyle/0-README.html">
            
                <a href="../../TOOLS/checkstyle/0-README.html">
            
                    
                        <b>4.2.</b>
                    
                    checkstyle
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.2.1" data-path="../../TOOLS/checkstyle/checkstyle.xml.html">
            
                <a href="../../TOOLS/checkstyle/checkstyle.xml.html">
            
                    
                        <b>4.2.1.</b>
                    
                    checkstyle.xml
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2.2" data-path="../../TOOLS/checkstyle/githook使用checkstyle.html">
            
                <a href="../../TOOLS/checkstyle/githook使用checkstyle.html">
            
                    
                        <b>4.2.2.</b>
                    
                    githook使用checkstyle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2.3" data-path="../../TOOLS/checkstyle/pre-commit.html">
            
                <a href="../../TOOLS/checkstyle/pre-commit.html">
            
                    
                        <b>4.2.3.</b>
                    
                    pre-commit
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../../TOOLS/docker/0-README.html">
            
                <a href="../../TOOLS/docker/0-README.html">
            
                    
                        <b>4.3.</b>
                    
                    docker
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.3.1" data-path="../../TOOLS/docker/Docker 常用命令.html">
            
                <a href="../../TOOLS/docker/Docker 常用命令.html">
            
                    
                        <b>4.3.1.</b>
                    
                    Docker 常用命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.2" data-path="../../TOOLS/docker/deepin中安装docker.html">
            
                <a href="../../TOOLS/docker/deepin中安装docker.html">
            
                    
                        <b>4.3.2.</b>
                    
                    deepin中安装docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.3" data-path="../../TOOLS/docker/docker-compose安装.html">
            
                <a href="../../TOOLS/docker/docker-compose安装.html">
            
                    
                        <b>4.3.3.</b>
                    
                    docker-compose安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.4" data-path="../../TOOLS/docker/docker-compose简化docker命令.html">
            
                <a href="../../TOOLS/docker/docker-compose简化docker命令.html">
            
                    
                        <b>4.3.4.</b>
                    
                    docker-compose简化docker命令
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../../TOOLS/git/0-README.html">
            
                <a href="../../TOOLS/git/0-README.html">
            
                    
                        <b>4.4.</b>
                    
                    git
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.4.1" data-path="../../TOOLS/git/[11769588]git配置多仓库.html">
            
                <a href="../../TOOLS/git/[11769588]git配置多仓库.html">
            
                    
                        <b>4.4.1.</b>
                    
                    git配置多仓库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.2" data-path="../../TOOLS/git/各GIt仓库的api.html">
            
                <a href="../../TOOLS/git/各GIt仓库的api.html">
            
                    
                        <b>4.4.2.</b>
                    
                    各GIt仓库的api
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../../TOOLS/ssh/0-README.html">
            
                <a href="../../TOOLS/ssh/0-README.html">
            
                    
                        <b>4.5.</b>
                    
                    ssh
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.5.1" data-path="../../TOOLS/ssh/ssh配置公钥私钥登录服务器.html">
            
                <a href="../../TOOLS/ssh/ssh配置公钥私钥登录服务器.html">
            
                    
                        <b>4.5.1.</b>
                    
                    ssh配置公钥私钥登录服务器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5.2" data-path="../../TOOLS/ssh/ssh配置跳板机-带密钥.html">
            
                <a href="../../TOOLS/ssh/ssh配置跳板机-带密钥.html">
            
                    
                        <b>4.5.2.</b>
                    
                    ssh配置跳板机-带密钥
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="../../TOOLS/sublime/0-README.html">
            
                <a href="../../TOOLS/sublime/0-README.html">
            
                    
                        <b>4.6.</b>
                    
                    sublime
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.6.1" data-path="../../TOOLS/sublime/sublime使用笔记.html">
            
                <a href="../../TOOLS/sublime/sublime使用笔记.html">
            
                    
                        <b>4.6.1.</b>
                    
                    sublime使用笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6.2" data-path="../../TOOLS/sublime/sublime替换本地记事本.html">
            
                <a href="../../TOOLS/sublime/sublime替换本地记事本.html">
            
                    
                        <b>4.6.2.</b>
                    
                    sublime替换本地记事本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6.3" data-path="../../TOOLS/sublime/去掉升级提醒.html">
            
                <a href="../../TOOLS/sublime/去掉升级提醒.html">
            
                    
                        <b>4.6.3.</b>
                    
                    去掉升级提醒
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.7" >
            
                <span>
            
                    
                        <b>4.7.</b>
                    
                    Spring
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" >
            
                <span>
            
                    
                        <b>4.8.</b>
                    
                    cglib
            
                </span>
            

            
        </li>
    

    
        
        <li class="header">前端</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../../前端/blog/0-README.html">
            
                <a href="../../前端/blog/0-README.html">
            
                    
                        <b>5.1.</b>
                    
                    blog
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../../前端/chrome/0-README.html">
            
                <a href="../../前端/chrome/0-README.html">
            
                    
                        <b>5.2.</b>
                    
                    chrome
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.2.1" data-path="../../前端/chrome/or01-扩展插件开发.html">
            
                <a href="../../前端/chrome/or01-扩展插件开发.html">
            
                    
                        <b>5.2.1.</b>
                    
                    扩展插件开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2.2" data-path="../../前端/chrome/or02-禁用chrome的快捷键.html">
            
                <a href="../../前端/chrome/or02-禁用chrome的快捷键.html">
            
                    
                        <b>5.2.2.</b>
                    
                    禁用chrome的快捷键
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2.3" data-path="../../前端/chrome/or03-小工具插件.html">
            
                <a href="../../前端/chrome/or03-小工具插件.html">
            
                    
                        <b>5.2.3.</b>
                    
                    小工具插件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../../前端/gitbook/0-README.html">
            
                <a href="../../前端/gitbook/0-README.html">
            
                    
                        <b>5.3.</b>
                    
                    gitbook
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">小记</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../../小记/游戏/0-README.html">
            
                <a href="../../小记/游戏/0-README.html">
            
                    
                        <b>6.1.</b>
                    
                    游戏
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1.1" data-path="../../小记/游戏/[12090043]重新机兵回归(MMR">
            
                <span>
            
                    
                        <b>6.1.1.</b>
                    
                    重新机兵回归(MMR)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.1.2" data-path="../../小记/游戏/上古卷轴5.html">
            
                <a href="../../小记/游戏/上古卷轴5.html">
            
                    
                        <b>6.1.2.</b>
                    
                    上古卷轴5
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../../小记/电影/0-README.html">
            
                <a href="../../小记/电影/0-README.html">
            
                    
                        <b>6.2.</b>
                    
                    电影
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.2.1" data-path="../../小记/电影/动画电影-和谐.html">
            
                <a href="../../小记/电影/动画电影-和谐.html">
            
                    
                        <b>6.2.1.</b>
                    
                    动画电影-和谐
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2.2" data-path="../../小记/电影/哈利波特.html">
            
                <a href="../../小记/电影/哈利波特.html">
            
                    
                        <b>6.2.2.</b>
                    
                    哈利波特
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2.3" data-path="../../小记/电影/永无止镜.html">
            
                <a href="../../小记/电影/永无止镜.html">
            
                    
                        <b>6.2.3.</b>
                    
                    永无止镜
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2.4" data-path="../../小记/电影/黑客帝国.html">
            
                <a href="../../小记/电影/黑客帝国.html">
            
                    
                        <b>6.2.4.</b>
                    
                    黑客帝国
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../../小记/目标/0-README.html">
            
                <a href="../../小记/目标/0-README.html">
            
                    
                        <b>6.3.</b>
                    
                    目标
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.3.1" data-path="../../小记/目标/淘宝店.html">
            
                <a href="../../小记/目标/淘宝店.html">
            
                    
                        <b>6.3.1.</b>
                    
                    淘宝店
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../../小记/眼球震颤/0-README.html">
            
                <a href="../../小记/眼球震颤/0-README.html">
            
                    
                        <b>6.4.</b>
                    
                    眼球震颤
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >Flink中Keyby和线程数的疑问</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="flink-&#x4E2D;-keyby-&#x548C;&#x7EBF;&#x7A0B;&#x6570;"><a name="flink-&#x4E2D;-keyby-&#x548C;&#x7EBF;&#x7A0B;&#x6570;" class="anchor-navigation-ex-anchor" href="#flink-&#x4E2D;-keyby-&#x548C;&#x7EBF;&#x7A0B;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>Flink &#x4E2D; keyby &#x548C;&#x7EBF;&#x7A0B;&#x6570;</h2>
<h3 id="standalone-&#x5355;&#x673A;&#x6A21;&#x5F0F;"><a name="standalone-&#x5355;&#x673A;&#x6A21;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#standalone-&#x5355;&#x673A;&#x6A21;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>standalone ,&#x5355;&#x673A;&#x6A21;&#x5F0F;</h3>
<p>&#x5B66;&#x4E60;&#x4E2D;&#x81EA;&#x5DF1;&#x64CD;&#x4F5C;&#x7684;&#x5C0F;&#x4F8B;&#x5B50;:</p>
<h4 id="&#x4E0D;&#x4F7F;&#x7528;keyby"><a name="&#x4E0D;&#x4F7F;&#x7528;keyby" class="anchor-navigation-ex-anchor" href="#&#x4E0D;&#x4F7F;&#x7528;keyby"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E0D;&#x4F7F;&#x7528;keyby</h4>
<pre class="language-"><code>    static AtomicLong cache = new AtomicLong();

    public static void main(String[] args) throws Exception {
        //&#x6D41;&#x5904;&#x7406;&#x73AF;&#x5883;
        StreamExecutionEnvironment sEnv = StreamExecutionEnvironment.getExecutionEnvironment();
        //&#x8BBE;&#x7F6E;&#x73AF;&#x5883;&#x7684;&#x7EBF;&#x7A0B;&#x6570;,&#x8FD9;&#x4E2A;&#x73AF;&#x5883;&#x4E0B;&#x5C31;&#x53EA;&#x6709;&#x8FD9;&#x4E9B;&#x6570;&#x91CF;&#x7684;&#x7EBF;&#x7A0B;
        sEnv
//        .setParallelism(2)
        //&#x6DFB;&#x52A0;&#x6570;&#x636E;&#x6E90;
        .addSource(new sourceFunction())
        //&#x6267;&#x884C;&#x6570;&#x636E;&#x64CD;&#x4F5C;
        .flatMap(new Nums())
        //&#x8F93;&#x51FA;&#x6570;&#x636E;
        .addSink(new sinkFunction());
        //&#x5F00;&#x59CB;&#x6267;&#x884C;
        sEnv.execute();
    }

    ................

    static class Nums implements FlatMapFunction<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>Integer,</span> <span class="token attr-name">Tuple1&lt;Long</span><span class="token punctuation">&gt;</span></span>&gt; {
        //&#x64CD;&#x4F5C;&#x6570;&#x636E;
        //&#x4ECE;cache&#x4E0A;&#x7D2F;&#x52A0; , &#x5E76;&#x8FD4;&#x56DE;
        @Override
        public void flatMap(Integer value, Collector&lt;Tuple1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>Long</span><span class="token punctuation">&gt;</span></span>&gt; out) throws Exception {
            long l = cache.addAndGet(value.longValue());
            System.out.println(Thread.currentThread().getName() + &quot; - &quot; + l);
            out.collect(new Tuple1&lt;&gt;(l));
        }
    }
</code></pre><p>&#x7136;&#x540E;&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x662F;:</p>
<pre class="language-"><code>Flat Map -&gt; Sink: Unnamed (2/6) - 1
Flat Map -&gt; Sink: Unnamed (3/6) - 2
Flat Map -&gt; Sink: Unnamed (4/6) - 3
Flat Map -&gt; Sink: Unnamed (5/6) - 4
Flat Map -&gt; Sink: Unnamed (6/6) - 5
Flat Map -&gt; Sink: Unnamed (1/6) - 6
Flat Map -&gt; Sink: Unnamed (2/6) - 7
Flat Map -&gt; Sink: Unnamed (3/6) - 8
</code></pre><p>&#x9ED8;&#x8BA4;&#x7EBF;&#x7A0B;&#x603B;&#x6570;&#x91CF;&#x662F;&#x6211;&#x7684;cpu&#x7684;&#x6838;&#x5FC3;&#x7EBF;&#x7A0B;&#x6570;. &#x7136;&#x540E;&#x662F;&#x6EE1;&#x7EBF;&#x7A0B;&#x6267;&#x884C; . </p>
<h4 id="&#x4F7F;&#x7528;keyby"><a name="&#x4F7F;&#x7528;keyby" class="anchor-navigation-ex-anchor" href="#&#x4F7F;&#x7528;keyby"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4F7F;&#x7528;keyby</h4>
<p>&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x7D2F;&#x52A0;&#x64CD;&#x4F5C;</p>
<pre class="language-"><code>    public static void main(String[] args) throws Exception {
        //&#x6D41;&#x5904;&#x7406;&#x73AF;&#x5883;
        StreamExecutionEnvironment sEnv = StreamExecutionEnvironment.getExecutionEnvironment();
        //&#x8BBE;&#x7F6E;&#x73AF;&#x5883;&#x7684;&#x7EBF;&#x7A0B;&#x6570;,&#x8FD9;&#x4E2A;&#x73AF;&#x5883;&#x4E0B;&#x5C31;&#x53EA;&#x6709;&#x8FD9;&#x4E9B;&#x6570;&#x91CF;&#x7684;&#x7EBF;&#x7A0B;
        sEnv
        //&#x6DFB;&#x52A0;&#x6570;&#x636E;&#x6E90;
        .addSource(new sourceFunction())
        .keyBy(0)
        //&#x6267;&#x884C;&#x6570;&#x636E;&#x64CD;&#x4F5C;
        .flatMap(new Nums())
        //&#x8F93;&#x51FA;&#x6570;&#x636E;
        .addSink(new sinkFunction());
        //&#x5F00;&#x59CB;&#x6267;&#x884C;
        sEnv.execute();
    }
    //&#x7701;&#x7565;&#x90E8;&#x5206;&#x4EE3;&#x7801;
    static class Nums extends RichFlatMapFunction&lt;Tuple1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>Integer</span><span class="token punctuation">&gt;</span></span>, Tuple1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>Long</span><span class="token punctuation">&gt;</span></span>&gt; {
        //&#x4F7F;&#x7528;valueState&#x4FDD;&#x5B58;
        private ValueState<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>Integer</span><span class="token punctuation">&gt;</span></span> valueState;

        @Override
        public void open(Configuration parameters) throws Exception {
            ValueStateDescriptor<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>Integer</span><span class="token punctuation">&gt;</span></span> cache = new ValueStateDescriptor&lt;&gt;(&quot;cache&quot;, Types.INT);
            this.valueState= getRuntimeContext().getState(cache);
        }

        //&#x64CD;&#x4F5C;&#x6570;&#x636E;
        //&#x4ECE;cache&#x4E0A;&#x7D2F;&#x52A0; , &#x5E76;&#x8FD4;&#x56DE;
        @Override
        public void flatMap(Tuple1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>Integer</span><span class="token punctuation">&gt;</span></span> value, Collector&lt;Tuple1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>Long</span><span class="token punctuation">&gt;</span></span>&gt; out) throws Exception {
            Integer cache = Optional.ofNullable(valueState.value()).orElse(0);
            int sum = cache + value.f0;
            valueState.update(sum);
            System.out.println(Thread.currentThread().getName() + &quot; - &quot; +value.f0);
            out.collect(new Tuple1&lt;&gt;(sum * 1L));
        }
    }
</code></pre><h6 id="&#x4E00;-&#x56FA;&#x5B9A;&#x7D2F;&#x52A0;1"><a name="&#x4E00;-&#x56FA;&#x5B9A;&#x7D2F;&#x52A0;1" class="anchor-navigation-ex-anchor" href="#&#x4E00;-&#x56FA;&#x5B9A;&#x7D2F;&#x52A0;1"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E00;) &#x56FA;&#x5B9A;&#x7D2F;&#x52A0;1</h6>
<p>&#x5F97;&#x5230;&#x5982;&#x4E0B;&#x7ED3;&#x679C;:</p>
<pre class="language-"><code>Flat Map -&gt; Sink: Unnamed (5/6) - 1
Flat Map -&gt; Sink: Unnamed (5/6) - 1
Flat Map -&gt; Sink: Unnamed (5/6) - 1
Flat Map -&gt; Sink: Unnamed (5/6) - 1
Flat Map -&gt; Sink: Unnamed (5/6) - 1
Flat Map -&gt; Sink: Unnamed (5/6) - 1
Flat Map -&gt; Sink: Unnamed (5/6) - 1
</code></pre><p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x56FA;&#x5B9A;&#x7EBF;&#x7A0B;&#x6267;&#x884C;. 
&#x4E5F;&#x5C31;&#x662F;&#x8BF4;<code>keyby</code>&#x4F1A;&#x505A;&#x6570;&#x636E;&#x548C;&#x7EBF;&#x7A0B;&#x7684;&#x5212;&#x5206;,&#x4E00;&#x7C7B;&#x6570;&#x636E;&#x53EA;&#x6709;&#x540C;&#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#x6267;&#x884C;.</p>
<h6 id="&#x4E8C;-&#x8BD5;&#x8BD5;&#x7D2F;&#x52A0;1&#x6216;2&#x4E24;&#x4E2A;&#x6570;&#x5B57;"><a name="&#x4E8C;-&#x8BD5;&#x8BD5;&#x7D2F;&#x52A0;1&#x6216;2&#x4E24;&#x4E2A;&#x6570;&#x5B57;" class="anchor-navigation-ex-anchor" href="#&#x4E8C;-&#x8BD5;&#x8BD5;&#x7D2F;&#x52A0;1&#x6216;2&#x4E24;&#x4E2A;&#x6570;&#x5B57;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E8C;) &#x8BD5;&#x8BD5;&#x7D2F;&#x52A0;1&#x6216;2,&#x4E24;&#x4E2A;&#x6570;&#x5B57;</h6>
<p>&#x5F97;&#x5230;&#x5982;&#x4E0B;&#x7ED3;&#x679C;:</p>
<pre class="language-"><code>Flat Map -&gt; Sink: Unnamed (6/6) - 2
Flat Map -&gt; Sink: Unnamed (6/6) - 2
Flat Map -&gt; Sink: Unnamed (5/6) - 1
Flat Map -&gt; Sink: Unnamed (5/6) - 1
Flat Map -&gt; Sink: Unnamed (5/6) - 1
Flat Map -&gt; Sink: Unnamed (6/6) - 2
Flat Map -&gt; Sink: Unnamed (6/6) - 2
Flat Map -&gt; Sink: Unnamed (5/6) - 1
Flat Map -&gt; Sink: Unnamed (5/6) - 1
Flat Map -&gt; Sink: Unnamed (5/6) - 1
</code></pre><p>&#x54C8;&#x54C8;&#x54C8;, &#x679C;&#x7136; , &#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#x53EA;&#x5904;&#x7406;&#x4E00;&#x7C7B;&#x6570;&#x636E;.</p>
<p>Flink&#x5DF2;&#x7ECF;&#x5E2E;&#x6211;&#x4EEC;&#x5904;&#x7406;&#x597D;&#x4E86;. &#x5F53;<code>keyby</code>&#x7684;&#x5B57;&#x6BB5;&#x6709;&#x591A;&#x4E2A;&#x503C;&#x65F6; , &#x6BCF;&#x4E2A;&#x503C;&#x90FD;&#x4F1A;&#x6709;&#x5355;&#x72EC;&#x7684;&#x7EBF;&#x7A0B;&#x53BB;&#x6267;&#x884C;.</p>
<h3 id="&#x96C6;&#x7FA4;&#x6A21;&#x5F0F;"><a name="&#x96C6;&#x7FA4;&#x6A21;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#&#x96C6;&#x7FA4;&#x6A21;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x96C6;&#x7FA4;&#x6A21;&#x5F0F;</h3>
<p>&#x5148;&#x8BB0;&#x4E2A;&#x70B9; </p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; jisong.fun  all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2020-04-14 13:59:59
</span></footer> <link rel="stylesheet" type="text/css" href="https://storage.googleapis.com/app.klipse.tech/css/codemirror.css"> <script>     window.klipse_settings = {         selector: ".language-klipse, .lang-eval-clojure",         selector_eval_js: ".lang-eval-js",         selector_eval_python_client: ".lang-eval-python",         selector_eval_php: ".lang-eval-php",         selector_eval_scheme: ".lang-eval-scheme",         selector_eval_ruby: ".lang-eval-ruby",         selector_reagent: ".lang-reagent",        selector_google_charts: ".lang-google-chart",        selector_es2017: ".lang-eval-es2017",        selector_jsx: ".lang-eval-jsx",        selector_transpile_jsx: ".lang-transpile-jsx",        selector_render_jsx: ".lang-render-jsx",        selector_react: ".lang-react",        selector_eval_markdown: ".lang-render-markdown",        selector_eval_lambdaway: ".lang-render-lambdaway",        selector_eval_cpp: ".lang-eval-cpp",        selector_eval_html: ".lang-render-html",        selector_sql: ".lang-eval-sql",        selector_brainfuck: "lang-eval-brainfuck",        selector_js: ".lang-transpile-cljs"    }; </script> <script src="https://storage.googleapis.com/app.klipse.tech/plugin/js/klipse_plugin.js"></script>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="or01-初学 Flink.html" class="navigation navigation-prev " aria-label="Previous page: 初学 Flink">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="or03-Flink-Spark-Storm的区别.html" class="navigation navigation-next " aria-label="Next page: Flink-Spark-Storm的区别">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Flink中Keyby和线程数的疑问","level":"2.1.2","depth":2,"next":{"title":"Flink-Spark-Storm的区别","level":"2.1.3","depth":2,"path":"Developer/Flink/or03-Flink-Spark-Storm的区别.md","ref":"Developer/Flink/or03-Flink-Spark-Storm的区别.md","articles":[]},"previous":{"title":"初学 Flink","level":"2.1.1","depth":2,"path":"Developer/Flink/or01-初学 Flink.md","ref":"Developer/Flink/or01-初学 Flink.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","-search","-highlight","-livereload","search-plus@^0.0.11","simple-page-toc@^0.1.1","-github@^2.0.0","-github-buttons@2.1.0","-edit-link@^2.0.2","-disqus@^0.1.0","prism@^2.1.0","prism-themes@^0.0.2","advanced-emoji@^0.2.1","anchors@^0.7.1","include-codeblock@^3.0.2","ace@^0.3.2","emphasize@^1.1.0","-katex@^1.1.3","splitter@^0.0.8","mermaid-gb3@2.1.0","tbfed-pagefooter@^0.0.1","expandable-chapters-small@^0.1.7","sectionx@^3.1.0","-donate@^1.0.2","-local-video@^1.0.1","-sitemap-general@^0.1.1","anchor-navigation-ex@0.1.8","favicon@^0.0.2","todo@^0.1.3","3-ba@^0.9.0","-terminal@^0.3.2","-alerts@^0.2.0","include-csv@^0.1.0","puml@^1.0.1","musicxml@^1.0.2","klipse@^1.2.0","-versions-select@^0.1.1","-rss@^3.0.2","-sharing","sharing-plus@^0.0.2","graph@^0.1.0","chart@^0.2.0","summary"],"root":".","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright © jisong.fun ","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prism-themes/themes/prism-base16-ateliersulphurpool.light.css"]},"include-csv":{},"disqus":{"shortName":"note-book"},"emphasize":{},"ace":{},"github":{"url":"https://gitee.com/ji-song/note-book"},"puml":{},"simple-page-toc":{"maxDepth":3,"skipFirstH1":true},"todo":{},"summary":{"excludeDir":["assets","styles","**/assets","resources"],"readme":"0-README.md","introduction":{"title":"继松的笔记","file":"README.md"}},"splitter":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"graph":{},"donate":{"wechat":"https://ji-song.com/resource/weixin.png","alipay":"https://ji-song.com/resource/alipay.png","title":"","button":"赏","alipayText":"支付宝打赏","wechatText":"微信打赏"},"sitemap-general":{"prefix":"http://gitbook.ji-song.com"},"fontsettings":{"theme":"white","family":"sans","size":2},"rss":{"title":"继松的书","description":"记录点滴","author":"JiSong Sun","feed_url":"http://gitbook.ji-song.com/rss","site_url":"http://gitbook.ji-song.com/","managingEditor":"me@ji-song.com","webMaster":"me@ji-song.com","categories":["gitbook"]},"musicxml":{},"sectionx":{"tag":"b"},"mermaid-gb3":{},"anchor-navigation-ex":{"isRewritePageTitle":false,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"},"favicon":{"shortcut":"favicon.ico","bookmark":"favicon.ico"},"prism-themes":{},"github-buttons":{"repo":"ji-song/note-book","types":["star"],"size":"small"},"3-ba":{"configuration":"auto","token":"ff100361cdce95dd4c8fb96b4009f7bc"},"expandable-chapters-small":{},"klipse":{"myConfigKey":"it's the default value"},"versions":{"options":[{"value":"http://gitbook.ji-song.com","text":"v3.2.3"},{"value":"http://gitbook.ji-song.com/v2/","text":"v2.6.4"}]},"advanced-emoji":{"embedEmojis":false},"include-codeblock":{"check":false,"edit":true,"fixlang":false,"lang":"","template":"ace","theme":"chrome","unindent":true},"sharing":{"qq":false,"all":["facebook","google","twitter","weibo","instapaper","linkedin","pocket","stumbleupon","qq","qzone"],"douban":false,"facebook":false,"weibo":true,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":true,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":true},"terminal":{"copyButtons":true,"fade":false,"style":"flat"},"edit-link":{"base":"https://github.com/ji-song/gitbook-use/edit/master","label":"Edit This Page"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"anchors":{},"chart":{"type":"c3"},"search-plus":{}},"theme":"default","author":"jisong","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"继松的书","language":"zh-hans","output.name":"site","links":{"sidebar":{"Home":"http://ji-song.gitee.io/cc"}},"gitbook":"3.2.3","description":"记录点滴"},"file":{"path":"Developer/Flink/or02-Flink中Keyby和线程数的疑问.md","mtime":"2020-04-14T05:59:59.437Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-04-14T08:13:26.502Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-ace/ace/ace.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-ace/ace.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-3-ba/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-musicxml/osmd.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-musicxml/musicxml.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-musicxml/promise.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

